/*
 * @Author: wangjh wangjiahui0710@163.com
 * @Date: 2024-05-20 16:40:44
 * @LastEditors: wangjh wangjiahui0710@163.com
 * @LastEditTime: 2024-06-12 16:28:38
 * @FilePath: \hn-fire-product-mobile\vite.proxy.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import process from 'node:process';

import { HttpsProxyAgent } from 'https-proxy-agent';
import type { ConfigEnv, ProxyOptions } from 'vite';
import { loadEnv } from 'vite';

export function createProxy(config: ConfigEnv): Record<string, string | ProxyOptions> {
  const env = loadEnv(config.mode, process.cwd());

  const agent = new HttpsProxyAgent('http://192.168.2.44:1181');
  return {
    "/whManager": {
      //   agent: new HttpsProxyAgent("http://192.168.0.245:9081"),
      target: env.VITE_SERVER_URL_PROXY,
      changeOrigin: true,
    },
    "/resource": {
      //   agent: new HttpsProxyAgent("http://192.168.0.245:9081"),
      target: env.VITE_SERVER_URL_PROXY,
      changeOrigin: true,
    },
  };
}
